﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Lab6_Product
{
    public partial class frmStoreManagement : Form
    {
        
        public frmStoreManagement()
        {
            InitializeComponent();
            
         
        }

        private void viewAllProductsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            viewAllProducts();
        }

        // disable Close box
        private const int CP_NOCLOSE_BUTTON = 0x200;
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams myCp = base.CreateParams;
                myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON;
                return myCp;
            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            exit();
        }

        private void exit()
        {
            this.Dispose();
            this.Close();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            exit();
        }
        private void viewAllProducts()
        {
           frmViewAllProducts f = frmViewAllProducts.Instance; 
               f.Show();
               f.MdiParent = this;
            
       
        }

        private void btnAllProducts_Click(object sender, EventArgs e)
        {
            viewAllProducts();
        }

        private void logOutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            logOut();
        }

        private void btnLogOut_Click(object sender, EventArgs e)
        {
            logOut();
        }

        public void logOut()
        {
           DialogResult dr= MessageBox.Show("Do u really want to log out? (Back to the log in window)", "Back to log in", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
           if (dr == DialogResult.Yes)
           {
               frmLogin f = new frmLogin();
               f.Show();
               this.Hide();
           }
        }
    }
}
